package main

import (
	_ "fmt"
	"gitchina/CPTT4WeChat/data"
	"gitchina/CPTT4WeChat/filters"
	"gitchina/CPTT4WeChat/jobs"
	_ "gitchina/CPTT4WeChat/routers"
	"gitchina/CPTT4WeChat/util"
	"github.com/astaxie/beego"
	"os"
)

func main() {
	runmode := os.Getenv("CZRUNMODE")
	beego.BConfig.RunMode = runmode
	beego.LoadAppConfig("ini", "conf/app.conf")
	util.InitLogger(beego.BConfig.RunMode)
	data.InitOrm(beego.BConfig.RunMode)
	jobs.Start()

	if beego.BConfig.RunMode != "prod" {
		beego.BConfig.Log.AccessLogs = true
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"

	}

	adapter, config := util.GetLoggerProfile()
	beego.BConfig.Log.Outputs = map[string]string{adapter: config}
	beego.InsertFilter("/*", beego.BeforeRouter, filters.DebugFilterFunc)
	beego.Run()
}
